import React from 'react'
import Action from '../../../action/action'
import Store from '../../../store/store'
import ReactMixin from 'react-mixin'
import Reflux from 'reflux'

import SideNavBar from '../../../component/sideNavBar/sideNavBar'

export default class MyPayments extends React.Component{
    constructor(props){
        super(props);
        this.state = {
            userWallet: {}
        }
    }
    componentDidMount(){
        Action.getUserWallet(()=>{})
    }
    render(){
        let userWallet = this.state.userWallet,
            statue = "",
            list = [];
        userWallet.paymentList && userWallet.paymentList.map((obj,i)=>{
            switch (obj.type){
                case "支付" : statue = "-";break;
                case "提现" : statue = "-";break;
                case "退款" : statue = "+";break;
                case "返现" : statue = "+";break;
                case "充值" : statue = "+";break;
            }
            list.push(
                <li key={i}>
                    <div>
                        <h4>[ {obj.type} ]{obj.text}</h4>
                        <p>{obj.date}{obj.time}</p>
                    </div>
                    <span>{statue}￥{obj.money}</span>
                </li>
            )
        })
        return(
            <div className="myPayments">
                <ul>
                    {list}
                </ul>
                <SideNavBar/>
            </div>
        )
    }
}
ReactMixin.onClass(MyPayments,Reflux.connect(Store))